<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
      <el-form-item label="公司名称" prop="companynameId">
        <el-input
          v-model="queryParams.companynameId"
          placeholder="请输入公司名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="部门名称" prop="companydeptId">
        <el-input
          v-model="queryParams.companydeptId"
          placeholder="请输入部门名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="楼栋号" prop="buildingNum">
        <el-input
          v-model="queryParams.buildingNum"
          placeholder="请输入楼栋号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工号" prop="jobNum">
        <el-input
          v-model="queryParams.jobNum"
          placeholder="请输入工号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="岗位" prop="companyPost">
        <el-select v-model="queryParams.companyPost" placeholder="请选择岗位" clearable size="small">
          <el-option
            v-for="dict in companyPostOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="姓名" prop="jobName">
        <el-input
          v-model="queryParams.jobName"
          placeholder="请输入姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="性别" prop="sex">
        <el-select v-model="queryParams.sex" placeholder="请选择性别" clearable size="small">
          <el-option
            v-for="dict in sexOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="手机号码" prop="phoneNum">
        <el-input
          v-model="queryParams.phoneNum"
          placeholder="请输入手机号码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="身份证号" prop="idNum">
        <el-input
          v-model="queryParams.idNum"
          placeholder="请输入身份证号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="卡号" prop="cardNo">
        <el-input
          v-model="queryParams.cardNo"
          placeholder="请输入卡号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="是否发卡" prop="iscardIssue">-->
<!--        <el-input-->
<!--          v-model="queryParams.iscardIssue"-->
<!--          placeholder="请输入是否发卡"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--            <el-form-item label="授权状态" prop="iscardIssue">-->
<!--              <el-input-->
<!--                v-model="queryParams.iscardIssue"-->
<!--                placeholder="请输入是否发卡"-->
<!--                clearable-->
<!--                size="small"-->
<!--                @keyup.enter.native="handleQuery"-->
<!--              />-->
<!--            </el-form-item>-->
      <el-form-item label="民族" prop="nation">
        <el-input
          v-model="queryParams.nation"
          placeholder="请输入民族"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="籍贯" prop="nativePlace">
        <el-input
          v-model="queryParams.nativePlace"
          placeholder="请输入籍贯"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="地址" prop="address">
        <el-input
          v-model="queryParams.address"
          placeholder="请输入地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="银行卡号" prop="bankcardNo">
        <el-input
          v-model="queryParams.bankcardNo"
          placeholder="请输入银行卡号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学历" prop="educationBackground">
        <el-select v-model="queryParams.educationBackground" placeholder="请选择学历" clearable size="small">
          <el-option
            v-for="dict in educationBackgroundOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="技能等级" prop="skillLevel">
        <el-select v-model="queryParams.skillLevel" placeholder="请选择技能等级" clearable size="small">
          <el-option
            v-for="dict in skillLevelOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="企业评价" prop="valuationEnterprise">
        <el-select v-model="queryParams.valuationEnterprise" placeholder="请选择企业评价" clearable size="small">
          <el-option
            v-for="dict in valuationEnterpriseOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="同步状态" prop="synchronousRegime">
        <el-select v-model="queryParams.synchronousRegime" placeholder="请选择同步状态" clearable size="small">
          <el-option
            v-for="dict in synchronousRegimeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="所属劳务" prop="laborserviceCompanyId">
        <el-input
          v-model="queryParams.laborserviceCompanyId"
          placeholder="请输入所属劳务"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否上传" prop="isUploading">
        <el-select v-model="queryParams.isUploading" placeholder="请选择是否上传" clearable size="small">
          <el-option
            v-for="dict in isUploadingOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
<!--      <el-form-item label="备用1" prop="beiyong1">-->
<!--        <el-input-->
<!--          v-model="queryParams.beiyong1"-->
<!--          placeholder="请输入备用1"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="备用2" prop="beiyong2">-->
<!--        <el-input-->
<!--          v-model="queryParams.beiyong2"-->
<!--          placeholder="请输入备用2"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="创建时间" prop="crtime">-->
<!--        <el-date-picker clearable size="small" style="width: 200px"-->
<!--                        v-model="queryParams.crtime"-->
<!--                        type="date"-->
<!--                        value-format="yyyy-MM-dd"-->
<!--                        placeholder="选择创建时间">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="修改时间" prop="uptime">-->
<!--        <el-date-picker clearable size="small" style="width: 200px"-->
<!--                        v-model="queryParams.uptime"-->
<!--                        type="date"-->
<!--                        value-format="yyyy-MM-dd"-->
<!--                        placeholder="选择修改时间">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['lgdz:companyworker:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['lgdz:companyworker:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['lgdz:companyworker:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['lgdz:companyworker:export']"
        >导出</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="companyworkerList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
<!--      <el-table-column label="主键id" align="center" prop="id" />-->
      <el-table-column label="公司名称" align="center" prop="companynameId" />
      <el-table-column label="部门名称" align="center" prop="companydeptId" />
      <el-table-column label="楼栋号" align="center" prop="buildingNum" />
      <el-table-column label="工号" align="center" prop="jobNum" />
      <el-table-column label="岗位" align="center" prop="companyPost" :formatter="companyPostFormat" />
      <el-table-column label="姓名" align="center" prop="jobName" />
      <el-table-column label="授权照片" align="center" prop="phototFirst" width="105">
        <template slot-scope="scope">
          <img :src="scope.row.phototFirst" style="width: 80px;height: 100px">
        </template>
      </el-table-column>
      <el-table-column label="性别" align="center" prop="sex" :formatter="sexFormat" />
      <el-table-column label="手机号码" align="center" prop="phoneNum" width="105"/>
      <el-table-column label="身份证号" align="center" prop="idNum" width="110"/>
      <el-table-column label="卡号" align="center" prop="cardNo" width="130"/>
<!--      <el-table-column label="授权状态" align="center" prop="iscardIssue" />-->
      <el-table-column label="民族" align="center" prop="nation" />
      <el-table-column label="籍贯" align="center" prop="nativePlace" />
      <el-table-column label="地址" align="center" prop="address" />
      <el-table-column label="银行卡号" align="center" prop="bankcardNo" />
      <el-table-column label="学历" align="center" prop="educationBackground" :formatter="educationBackgroundFormat" />
      <el-table-column label="技能等级" align="center" prop="skillLevel" :formatter="skillLevelFormat" />
      <el-table-column label="企业评价" align="center" prop="valuationEnterprise" :formatter="valuationEnterpriseFormat" />

      <el-table-column label="照片二" align="center" prop="photoSecond">
        <template slot-scope="scope">
          <img :src="scope.row.photoSecond" style="width: 80px;height: 100px">
        </template>
      </el-table-column>
<!--      <el-table-column label="照片三" align="center" prop="photoThird" />-->
      <el-table-column label="照片注册" align="center" prop="isphotoRegister" :formatter="isphotoRegisterFormat" />
      <el-table-column label="同步状态" align="center" prop="synchronousRegime" :formatter="synchronousRegimeFormat" />
      <el-table-column label="所属劳务" align="center" prop="laborserviceCompanyId" />
      <el-table-column label="是否上传" align="center" prop="isUploading" :formatter="isUploadingFormat" />
<!--      <el-table-column label="备用1" align="center" prop="beiyong1" />-->
<!--      <el-table-column label="备用2" align="center" prop="beiyong2" />-->
      <el-table-column label="创建时间" align="center" prop="crtime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.crtime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="修改时间" align="center" prop="uptime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.uptime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['lgdz:companyworker:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['lgdz:companyworker:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改企业用户对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-row :gutter="15">
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row>
        <el-col :span="8">
        <el-form-item label="公司名称" prop="companynameId">
          <el-select v-model="form.companynameId" placeholder="请选择公司名称" clearable size="small" style="width: 100%">
            <el-option
              v-for="dict in yarg"
              :key="dict.id"
              :label="dict.companyName"
              :value="dict.id"
            />
          </el-select>
        </el-form-item>
        </el-col>
        <el-col :span="8">
        <el-form-item label="部门名称" prop="companydeptId">
<!--          <el-input v-model="form.companydeptId" placeholder="请输入部门名称" />-->
<!--          <el-select placeholder="请选择部门名称" v-model="form.companydeptId  " style="width: 100%">-->
<!--            <el-option :key="dist.id" :label="dist.compamyDept" :value="dist.id" v-for="dist in bumen"></el-option>-->
<!--          </el-select>-->
          <el-select v-model="form.companydeptId" placeholder="请选择部门名称" clearable size="small" style="width: 100%">
            <el-option
              v-for="dict in bumen"
              :key="dict.id"
              :label="dict.compamyDept"
              :value="dict.id"
            />
          </el-select>
        </el-form-item></el-col>
        <el-col :span="8">
        <el-form-item label="楼栋号" prop="buildingNum">
          <el-input v-model="form.buildingNum" placeholder="请输入楼栋号" />
        </el-form-item></el-col>
        </el-row>
        <el-col :span="8">
        <el-form-item label="工号" prop="jobNum">
          <el-input v-model="form.jobNum" placeholder="请输入工号" />
        </el-form-item></el-col>
        <el-col :span="8">
          <el-form-item label="姓名" prop="jobName">
            <el-input v-model="form.jobName" placeholder="请输入姓名" />
          </el-form-item></el-col>
        <el-col :span="8">
        <el-form-item label="岗位">
          <el-select v-model="form.companyPost" placeholder="请选择岗位" style="width: 100%">
            <el-option
              v-for="dict in companyPostOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item></el-col>

        <el-col :span="8">
        <el-form-item label="性别">
          <el-select v-model="form.sex" placeholder="请选择性别" style="width: 100%">
            <el-option
              v-for="dict in sexOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item></el-col>
        <el-col :span="8">
        <el-form-item label="手机号码" prop="phoneNum">
          <el-input v-model="form.phoneNum" placeholder="请输入手机号码" />
        </el-form-item></el-col>
        <el-col :span="8">
        <el-form-item label="身份证号" prop="idNum">
          <el-input v-model="form.idNum" placeholder="请输入身份证号" />
        </el-form-item></el-col>
        <el-col :span="8">
        <el-form-item label="卡号" prop="cardNo">
          <el-input v-model="form.cardNo" placeholder="请输入卡号" />
        </el-form-item></el-col>
<!--        <el-col :span="8">-->
<!--        <el-form-item label="是否发卡" prop="iscardIssue">-->
<!--          <el-input v-model="form.iscardIssue" placeholder="请输入是否发卡" />-->
<!--        </el-form-item>-->
<!--        </el-col>-->
        <el-col :span="8">
        <el-form-item label="民族" prop="nation">
          <el-input v-model="form.nation" placeholder="请输入民族" />
        </el-form-item></el-col>
        <el-col :span="8">
        <el-form-item label="籍贯" prop="nativePlace">
          <el-input v-model="form.nativePlace" placeholder="请输入籍贯" />
        </el-form-item></el-col>
        <el-col :span="8">
        <el-form-item label="地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入地址" />
        </el-form-item></el-col>
        <el-col :span="8">
        <el-form-item label="银行卡号" prop="bankcardNo">
          <el-input v-model="form.bankcardNo" placeholder="请输入银行卡号" />
        </el-form-item></el-col>
        <el-col :span="8">
        <el-form-item label="学历">
          <el-select v-model="form.educationBackground" placeholder="请选择学历" style="width: 100%">
            <el-option
              v-for="dict in educationBackgroundOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item></el-col>
        <el-col :span="8">
        <el-form-item label="技能等级">
          <el-select v-model="form.skillLevel" placeholder="请选择技能等级" style="width: 100%">
            <el-option
              v-for="dict in skillLevelOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item></el-col>
        <el-col :span="8">
        <el-form-item label="企业评价">
          <el-select v-model="form.valuationEnterprise" placeholder="请选择企业评价" style="width: 100%">
            <el-option
              v-for="dict in valuationEnterpriseOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item></el-col>
<!--        <el-form-item label="照片一" prop="phototFirst">-->
<!--          <el-input v-model="form.phototFirst" placeholder="请输入照片一" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="照片二" prop="photoSecond">-->
<!--          <el-input v-model="form.photoSecond" placeholder="请输入照片二" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="照片三" prop="photoThird">-->
<!--          <el-input v-model="form.photoThird" placeholder="请输入照片三" />-->
<!--        </el-form-item>-->
        <el-col :span="8">
        <el-form-item label="照片注册">
          <el-select v-model="form.isphotoRegister" placeholder="请选择照片注册" style="width: 100%">
            <el-option
              v-for="dict in isphotoRegisterOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item></el-col>
        <el-col :span="8">
        <el-form-item label="同步状态">
          <el-select v-model="form.synchronousRegime" placeholder="请选择同步状态" style="width: 100%">
            <el-option
              v-for="dict in synchronousRegimeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item></el-col>
        <el-col :span="8">
        <el-form-item label="所属劳务" prop="laborserviceCompanyId">
<!--          <el-input v-model="form.laborserviceCompanyId" placeholder="请输入所属劳务" />-->
          <el-select v-model="form.laborserviceCompanyId" placeholder="请输入所属劳务" style="width: 100%">
            <el-option
              v-for="dict in laowus"
              :key="dict.id"
              :label="dict.username"
              :value="dict.id"
            ></el-option>
          </el-select>
        </el-form-item></el-col>
        <el-col :span="8">
        <el-form-item label="是否上传">
          <el-select v-model="form.isUploading" placeholder="请选择是否上传" style="width: 100%">
            <el-option
              v-for="dict in isUploadingOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item></el-col>
<!--        <el-form-item label="备用1" prop="beiyong1">-->
<!--          <el-input v-model="form.beiyong1" placeholder="请输入备用1" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="备用2" prop="beiyong2">-->
<!--          <el-input v-model="form.beiyong2" placeholder="请输入备用2" />-->
<!--        </el-form-item>-->
<!--        <el-col :span="8">-->
<!--        <el-form-item label="创建时间" prop="crtime">-->
<!--          <el-date-picker clearable size="small" style="width: 100%"-->
<!--                          v-model="form.crtime"-->
<!--                          type="date"-->

<!--                          value-format="yyyy-MM-dd"-->
<!--                          placeholder="选择创建时间">-->
<!--          </el-date-picker>-->
<!--        </el-form-item></el-col>-->
<!--        <el-col :span="8">-->
<!--        <el-form-item label="修改时间" prop="uptime">-->
<!--          <el-date-picker clearable size="small" style="width: 100%"-->
<!--                          v-model="form.uptime"-->
<!--                          type="date"-->
<!--                          value-format="yyyy-MM-dd"-->
<!--                          placeholder="选择修改时间">-->
<!--          </el-date-picker>-->
<!--        </el-form-item></el-col>-->
        <el-col :span="24">
          <div>
            <span style="font-size: 18px;font-weight: 500">人员照片</span>
            <el-divider></el-divider>
          </div>
        </el-col>
        <el-col :span="12">
          <el-form-item label="授权照片" prop="phototFirst">
            <el-upload
              class="avatar-uploader"
              :action="actionUrl"
              :on-preview="handlePictureCardPreview"
              v-model="form.phototFirst"
              :on-change="getFile"
              :show-file-list="false">
              <img v-if="imageUrl" :src="this.imageUrl" class="avatar">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            </el-upload>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="身份证照片" prop="photoSecond">
            <el-upload
              class="avatar-uploader"
              :action="actionUrlSecond"
              :show-file-list="false"
              v-model="form.photoSecond"
              :on-change="getFileSecond">
              <img v-if="imageUrlSecond" :src="imageUrlSecond" class="avatar">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            </el-upload>
          </el-form-item>
        </el-col>
      </el-form>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import { listCompanyworker, getCompanyworker, delCompanyworker, addCompanyworker, updateCompanyworker, exportCompanyworker } from "@/api/lgdz/companyworker";
  import { listCompanyname } from "@/api/lgdz/companyname";
  // 部门
  import { listCompanydept } from "@/api/lgdz/companydept";
  import { listCompanydeviceinfo} from "@/api/lgdz/companydeviceinfo";
  export default {
    name: "Companyworker",
    data() {
      return {
        // 照片上传
        actionUrl:"",
        actionUrlSecond:"",
        actionUrlThird:"",
        imageUrl:"",
        opes:false,
        imageUrlSecond:"",
        imageUrlThird:"",
        yarg:[],
        bumen:[],
        iplist:[],
        laowus:[],
        xd:"",
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 总条数
        total: 0,
        // 企业用户表格数据
        companyworkerList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 岗位字典
        companyPostOptions: [],
        // 性别字典
        sexOptions: [],
        // 学历字典
        educationBackgroundOptions: [],
        // 技能等级字典
        skillLevelOptions: [],
        // 企业评价字典
        valuationEnterpriseOptions: [],
        // 照片注册字典
        isphotoRegisterOptions: [],
        // 同步状态字典
        synchronousRegimeOptions: [],
        // 是否上传字典
        isUploadingOptions: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          companynameId: undefined,
          companydeptId: undefined,
          buildingNum: undefined,
          jobNum: undefined,
          companyPost: undefined,
          jobName: undefined,
          sex: undefined,
          phoneNum: undefined,
          idNum: undefined,
          cardNo: undefined,
          iscardIssue: undefined,
          nation: undefined,
          nativePlace: undefined,
          address: undefined,
          bankcardNo: undefined,
          educationBackground: undefined,
          skillLevel: undefined,
          valuationEnterprise: undefined,
          synchronousRegime: undefined,
          laborserviceCompanyId: undefined,
          isUploading: undefined,
          beiyong1: undefined,
          beiyong2: undefined,
          crtime: undefined,
          uptime: undefined
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
          companynameId: [
            { required: true, message: "公司名称不能为空", trigger: "blur" }
          ],
          companydeptId: [
            { required: true, message: "部门名称不能为空", trigger: "blur" }
          ],
          jobNum: [
            { required: true, message: "工号不能为空", trigger: "blur" }
          ],
          companyPost: [
            { required: true, message: "岗位不能为空", trigger: "blur" }
          ],
          jobName: [
            { required: true, message: "姓名不能为空", trigger: "blur" }
          ],
          sex: [
            { required: true, message: "性别不能为空", trigger: "blur" }
          ],
          phoneNum: [
            { required: true, message: "手机号码不能为空", trigger: "blur" }
          ],
          idNum: [
            { required: true, message: "身份证号不能为空", trigger: "blur" }
          ],
          cardNo: [
            { required: true, message: "卡号不能为空", trigger: "blur" }
          ],
          bankcardNo: [
            { required: true, message: "银行卡号不能为空", trigger: "blur" }
          ],
          educationBackground: [
            { required: true, message: "学历不能为空", trigger: "blur" }
          ],
          skillLevel: [
            { required: true, message: "技能等级不能为空", trigger: "blur" }
          ],
          laborserviceCompanyId: [
            { required: true, message: "所属劳务不能为空", trigger: "blur" }
          ],
        }
      };
    },
    created() {
      this.getListbum()
      this.getListname()
      this.getList();
      this.getDicts("CompanyWorkerTable_Company_Post").then(response => {
        this.companyPostOptions = response.data;
      });
      this.getDicts("sys_user_sex").then(response => {
        this.sexOptions = response.data;
      });
      this.getDicts("CompanyWorker_Education_Background").then(response => {
        this.educationBackgroundOptions = response.data;
      });
      this.getDicts("CompanyWorkerTable_Skill_Level").then(response => {
        this.skillLevelOptions = response.data;
      });
      this.getDicts("CompanyWorker_Valuation_Enterprise").then(response => {
        this.valuationEnterpriseOptions = response.data;
      });
      this.getDicts("CompanyWorker_IsPhoto_Register").then(response => {
        this.isphotoRegisterOptions = response.data;
      });
      this.getDicts("companyworkerTable_Synchronous_Regime").then(response => {
        this.synchronousRegimeOptions = response.data;
      });
      this.getDicts("companyworkerTable_Is_Uploading").then(response => {
        this.isUploadingOptions = response.data;
      });
      this.laowu()
    },
    methods: {
        // 劳务查询
      laowu(){
        const api = " http://192.168.10.175:8088/lgdz/livebuildDockingplatform/getlabor";
        this.$axios({
          url: api,
          method: "get",
        }).then((res) => {
          // console.log(res);
          this.laowus=res.data.rows
        })
      },
      /** 查询企业用户列表 */
      getList() {
        this.loading = true;
        listCompanyworker(this.queryParams).then(response => {
          this.companyworkerList = response.rows;
          this.companyworkerList.forEach((item)=>{
            const api = "http://192.168.10.175:8088/device/queryCompanyName";
            this.$axios({
              url: api,
              method: "get",
              params:{
                companyId:item.companynameId
              }
              //用于表示用户代理是否在跨域请求的情况下从其他域中发送cookies
              //  withCredentials:true,//默认为false
            }).then((res) => {
              // console.log(res.data);
              item.companynameId=res.data
            })

          })
          this.companyworkerList.forEach((re)=>{
            const api = "http://192.168.10.175:8088/device/queryDeptNameById";
            this.$axios({
              url: api,
              method: "get",
              params:{
                DeptId:re.companydeptId
              }
            }).then((res) => {
              // console.log(res);
              re.companydeptId=res.data
            })
          })
          this.companyworkerList.forEach((cc)=>{
            const api = "http://192.168.10.175:8088/lgdz/livebuildDockingplatform/getlabel";
            this.$axios({
              url: api,
              method: "get",
              params:{
                id:cc.laborserviceCompanyId
              }
            }).then((res) => {
              // console.log(res);
              cc.laborserviceCompanyId=res.data
            })
          })
          this.total = response.total;
          this.loading = false;
        });
      },
      // 岗位字典翻译
      companyPostFormat(row, column) {
        return this.selectDictLabel(this.companyPostOptions, row.companyPost);
      },
      // 性别字典翻译
      sexFormat(row, column) {
        return this.selectDictLabel(this.sexOptions, row.sex);
      },
      // 学历字典翻译
      educationBackgroundFormat(row, column) {
        return this.selectDictLabel(this.educationBackgroundOptions, row.educationBackground);
      },
      // 技能等级字典翻译
      skillLevelFormat(row, column) {
        return this.selectDictLabel(this.skillLevelOptions, row.skillLevel);
      },
      // 企业评价字典翻译
      valuationEnterpriseFormat(row, column) {
        return this.selectDictLabel(this.valuationEnterpriseOptions, row.valuationEnterprise);
      },
      // 照片注册字典翻译
      isphotoRegisterFormat(row, column) {
        return this.selectDictLabel(this.isphotoRegisterOptions, row.isphotoRegister);
      },
      // 同步状态字典翻译
      synchronousRegimeFormat(row, column) {
        return this.selectDictLabel(this.synchronousRegimeOptions, row.synchronousRegime);
      },
      // 是否上传字典翻译
      isUploadingFormat(row, column) {
        return this.selectDictLabel(this.isUploadingOptions, row.isUploading);
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: undefined,
          companynameId: undefined,
          companydeptId: undefined,
          buildingNum: undefined,
          jobNum: undefined,
          companyPost: undefined,
          jobName: undefined,
          sex: undefined,
          phoneNum: undefined,
          idNum: undefined,
          cardNo: undefined,
          iscardIssue: undefined,
          nation: undefined,
          nativePlace: undefined,
          address: undefined,
          bankcardNo: undefined,
          educationBackground: undefined,
          skillLevel: undefined,
          valuationEnterprise: undefined,
          phototFirst: undefined,
          photoSecond: undefined,
          photoThird: undefined,
          isphotoRegister: undefined,
          synchronousRegime: undefined,
          laborserviceCompanyId: undefined,
          isUploading: undefined,
          beiyong1: undefined,
          beiyong2: undefined,
          crtime: undefined,
          uptime: undefined
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!=1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加企业用户";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const id = row.id || this.ids
        getCompanyworker(id).then(response => {
          this.form = response.data;
          this.open = true;
          this.title = "修改企业用户";
        });
      },
      /** 提交按钮 */
      submitForm: function() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.id != undefined) {
              updateCompanyworker(this.form).then(response => {
                if (response.code === 200) {
                  this.msgSuccess("修改成功");
                  this.open = false;
                  this.getList();
                } else {
                  this.msgError(response.msg);
                }
              });
            } else {
              addCompanyworker(this.form).then(response => {
                if (response.code === 200) {
                  this.msgSuccess("新增成功");
                  this.open = false;
                  this.imageUrl=""
                  this.imageUrlSecond=""
                  this.getList();
                } else {
                  this.msgError(response.msg);
                }
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$confirm('是否确认删除企业用户编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delCompanyworker(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
      },
      /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有企业用户数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportCompanyworker(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
      },
      /** 查询公司名称列表 */
      getListname() {
        listCompanyname(this.queryParams).then(response => {
          // console.log(response)
          this.yarg = response.rows;
        });
      },
      /** 查询公司部门列表 */
      getListbum() {
        listCompanydept(this.queryParams).then(response => {
          // console.log("部门")
          // console.log(response)
          this.bumen = response.rows;
        });
      },
      handlePictureCardPreview(file) {
        // this.dialogImageUrl = file.url;
        // this.dialogVisible = true;
        // console.log(file)
      },
      getFile(file) {
        //上传头像
        // console.log(file)
        this.getBase64(file.raw).then((res) => {
          // console.log(res)
          this.form.phototFirst=res
          // console.log(this.form.phototFirst)
          this.imageUrl = res
        })
      },
      getFileSecond(file) {
        //上传头像
        // console.log(file)
        this.getBase64(file.raw).then((res) => {
          // console.log(res)
          this.form.photoSecond=res
          // console.log(this.form.phototFirst)
          this.imageUrlSecond = res
        })
      },
      getFileThird(file) {
        //上传头像
        // console.log(file)
        this.getBase64(file.raw).then((res) => {
          // console.log(res)
          this.form.photoThird=res
          // console.log(this.form.phototFirst)
          this.imageUrlThird = res
        })
      },
      getBase64(file) {
        //把图片转成base64编码
        return new Promise(function(resolve, reject) {
          let reader = new FileReader()
          let imgResult = ''
          reader.readAsDataURL(file)
          // console.log(reader)
          reader.onload = function() {
            imgResult = reader.result
          }
          reader.onerror = function(error) {
            reject(error)
          }
          reader.onloadend = function() {
            resolve(imgResult)
          }
        })
      },
    }
  };
</script>
<style lang="less">
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  /*.el-button--medium {*/
  /*  padding: 10px 13px !important;*/
  /*  font-size: 14px;*/
  /*  border-radius: 4px;*/
  /*}*/
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>
